package com.gs.djys.checkfragments.opinion;

import android.app.Activity;
import android.content.Context;

import com.alibaba.fastjson.JSON;
import com.gs.djys.Base.AddBean;
import com.gs.djys.Base.MyAppliCation;
import com.gs.djys.Base.Urls;
import com.gs.djys.callback.StringDialogCallback;
import com.gs.djys.mvp.BasePresenterImpl;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;

/**
 * MVPPlugin
 *  邮箱 784787081@qq.com
 */

public class OpinionPresenter extends BasePresenterImpl<OpinionContract.View> implements OpinionContract.Presenter{
    @Override
    public void addData(String isty, String comments, Activity activity,String pic) {
        OkGo.<String>post(Urls.SERVER + "/road/lictran/licApp/zqyj/submitZqyj")
                .params("user_code", MyAppliCation.spUtils.getString("userCode"))
                .params("code", isty)
                .params("req_no", MyAppliCation.spUtils.getString("REQ_NO"))
                .params("comments",comments)
                .params("zqyj_img",pic)
                .execute(new StringDialogCallback(activity) {
                    @Override
                    public void onSuccess(Response<String> response) {
                        AddBean addBean = JSON.parseObject(response.body(),AddBean.class);
                        if (mView == null)
                            return;
                        if (addBean.getCode().equals("0000")){
                            mView.addDatas(addBean);
                        }else {
                            mView.onRequestError(addBean.getMessage());
                        }
                    }
                });
    }
}
